<?php
/**
 * @var $this Pinenut\Action
 * @var $message Messenger\Messages
 * @var $messageIsMine  bool
 * @var $messageIsReaded bool
 * @var $messageActionContent string
 * @var $messageSeen string
 */
$msgAuthor = $message->author->getEntity();

$avatarType = null;

if (method_exists($msgAuthor, 'getAvatarType')) {
	$avatarType = $msgAuthor->getAvatarType();
}

if (null !== $avatarType) {
	$avatarTypeClass .= '-profile';
}
?>

<div class="md-message <?php echo $messageIsMine ? 'md-my-message' : ''; ?>" order="<?php echo $message->sendTimestamp; ?>">
    <div class="md-main-info clearfix <?php echo $avatarTypeClass ?>">
			<div class="md-mi-avatar avatar-sm avatar-item"
				 <?php if (null === $avatarTypeClass) { ?>
					 style="background-image: url(<?php echo $this->url(
						'photos.thumb',
						['id' => $msgAuthor->getAvatar()->_id, 'thumb' => 'messenger']
					); ?>)"
				 <?php } ?>
			></div>
			<div class="md-mi-name">
				<?php echo $this->txt2html($msgAuthor->nickname); ?>
				<span class="md-mi-time" data-timestamp="<?= (int)($message->sendTimestamp / 10000); ?>"><?php echo date(DATE_ATOM, ($message->sendTimestamp / 10000)); ?></span>
			</div>
			<div class="md-mi-text">
				<?php if ($messageActionContent !== null) : ?>
					<?php echo $messageActionContent; ?>
				<?php endif; ?>
			</div>
    </div>
</div>